import requests
from config import url, headers_web


class Topic:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def get_like_topicid_personid(cls, url: str, params=None, headers=headers_web, paramspath=None,
                                  paramspath1=None):
        """
        Summary:根据topicid和personid判断当前人是否点过赞
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param paramspath:
        :param paramspath1:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/islike/{paramspath}/{paramspath1}"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_pageview_topicid(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        Summary:根据话题ID获取话题浏览数量
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/statisticspageviewnum/{paramspath}"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_likes_topicid(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        Summary:根据topicid获取话题点赞数量
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/statisticslikenum/{paramspath}"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_topic_detail_topicid(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        Summary:根据话题ID获取本条话题详细信息
        Description:调用方：1，云课堂老师端 2,云课堂老师端 3，云课堂管理端
        :param url:
        :param params:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/{paramspath}"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def post_save_topic(cls, url: str, params=None, headers=headers_web, json=None):
        """
        Summary:保存话题对象
        Description:调用方：1，云课堂老师端
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/topic/save"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_topic_list(cls, url: str, params=None, headers=headers_web, json=None):
        """
        Summary:根据查询条件获取话题列表
        Description:调用方：1，云课堂管理端2，云课堂老师端 3，云课堂学生端
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/topic/topiclist"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_remove_like(cls, url: str, params=None, headers=headers_web, json=None):
        """
        Summary:移除话题点赞
        Description:调用方：1，云课堂老师端 2，云课堂学生端
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/topic/dellike"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_save_like(cls, url: str, params=None, headers=headers_web, json=None):
        """
        Summary:保存话题点赞对象
        Description:调用方：1，云课堂老师端 2，云课堂学生端
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/topic/savelike"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_delete_topic(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        Summary:根据话题ID删除本条话题
        Description:调用方：1，云课堂老师端
        :param url:
        :param params:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/deletetopic/{paramspath}"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_pageview_topicid(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        Summary:根据话题ID增加话题浏览数量
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/pageviewnum/{paramspath}"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_savereply(cls, url: str, params=None, headers=headers_web, json=None):
        """
        Summary:保存话题回复对象 或 修改回复的隐藏和显示状态
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param json:
        :return:
        """
        url = url + "/teachingApi/v1/topic/savereply"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_replylist(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        Summary:根据话题获取里评论列表
        Description:调用方：1，云课堂老师端 2，云课堂学生端 3，云课堂管理端
        :param url:
        :param params:
        :param json:
        :param paramspath:
        :return:
        """
        url = url + f"/teachingApi/v1/topic/replylist/{paramspath}"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r
